import { Component, Hook, Mut, VueComponent } from 'vue3-oop'
import { NSpin } from 'naive-ui'
import styles from './root.module.scss'
import RootApi from './root.api'

@Component()
export default class RootView extends VueComponent {
  constructor() {
    super()
  }

  @Mut() state = {

  }

  @Hook('Mounted')
  onMounted(){
    RootApi.userInfo().then(({status,data})=>{
      // console.log(status,data)
      window.$router.push("/main")
    }).catch((reason)=>{
      // console.log(reason.response)
      window.$router.push("/signin")
    })


  }

  render() {
    return (
      <div
        class={[styles['root']]}
      >
        <NSpin
          description={"加载中，请稍后……"}
          size={200}
        />
      </div>
    )
  }
}
